/*
 * @Author: 黄达全
 * @Date: 2024-07-19 16:09:02
 * @LastEditTime: 2024-07-20 18:26:45
 */
import el_zh_cn from 'element-plus/es/locale/lang/zh-cn'
import el_en from 'element-plus/es/locale/lang/en'
import { createI18n, LocaleMessages ,I18nOptions} from 'vue-i18n';

import zh_cn from './lang/zh-cn';
import en from './lang/en';
import tool from '@/utils/tool';
import sysConfig from "@/config"

type MessageSchema = {
    el: typeof el_zh_cn | typeof el_en;
    [key: string]: any;
}

const messages:LocaleMessages<MessageSchema>={
    'zh-cn':{
        el: el_zh_cn,
        ...zh_cn
    },
    'en':{
        el: el_en,
        ...en
    }
}

const ii8n=createI18n({
    locale: tool.data.get("APP_LANG") ||  sysConfig.LANG,
    legacy:false,
    fallbackLocale:"zh-cn",
    globalInjection:true,
    messages
} as I18nOptions)

export default ii8n;